home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C & C++ Multimedia Cyber Classroom
/
C and C++ Multimedia Cyber Classroom (Prentice Hall) (1998).iso
/
src
/
fig10_01.jar
/
Ch10
/
Fig10_01
/
Commis1.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1997-10-28
|
1KB
|
39 lines
// Fig. 10.1: commis1.cpp
// Member function definitions for class CommissionWorker
#include <iostream.h>
#include "commis1.h"
// Constructor for class CommissionWorker
CommissionWorker::CommissionWorker( const char *first,
const char *last, double s, double c, int q )
: Employee( first, last ) // call base-class constructor
{
setSalary( s );
setCommission( c );
setQuantity( q );
}
// Set CommissionWorker's weekly base salary
void CommissionWorker::setSalary( double s )
{ salary = s > 0 ? s : 0; }
// Set CommissionWorker's commission
void CommissionWorker::setCommission( double c )
{ commission = c > 0 ? c : 0; }
// Set CommissionWorker's quantity sold
void CommissionWorker::setQuantity( int q )
{ quantity = q > 0 ? q : 0; }
// Determine CommissionWorker's earnings
double CommissionWorker::earnings() const
{ return salary + commission * quantity; }
// Print the CommissionWorker's name
void CommissionWorker::print() const
{
cout << "\nCommission worker: ";
Employee::print();
}